<?php 
add_action( 'admin_enqueue_scripts', 'import_epanel_javascript' );
function import_epanel_javascript( $hook_suffix ) {
	if ( 'admin.php' == $hook_suffix && 'wordpress' == $_GET['import'] && '1' == $_GET['step'] )
		add_action( 'admin_head', 'admin_headhook' );
}

function admin_headhook(){ ?>
	<script type="text/javascript">
		jQuery(document).ready(function($){
			$("p.submit").before("<p><input type='checkbox' id='importepanel' name='importepanel' value='1' style='margin-right: 5px;'><label for='importepanel'>Replace ePanel settings with sample data values</label></p>");
		});
	</script>
<?php }

add_action('import_end','importend');
function importend(){
	if ( !isset($_POST['importepanel']) )
		return;
	
	$importOptions = 'YToxMDE6e3M6MDoiIjtOO3M6MTQ6ImRlZXBmb2N1c19sb2dvIjtzOjA6IiI7czoxNzoiZGVlcGZvY3VzX2Zhdmljb24iO3M6MDoiIjtzOjIyOiJkZWVwZm9jdXNfY29sb3Jfc2NoZW1lIjtzOjc6IkRlZmF1bHQiO3M6MjA6ImRlZXBmb2N1c19ibG9nX3N0eWxlIjtOO3M6MjA6ImRlZXBmb2N1c19ncmFiX2ltYWdlIjtOO3M6MTg6ImRlZXBmb2N1c19ibG9nX2NhdCI7czo0OiJCbG9nIjtzOjIyOiJkZWVwZm9jdXNfY2F0bnVtX3Bvc3RzIjtzOjI6IjEyIjtzOjI2OiJkZWVwZm9jdXNfYXJjaGl2ZW51bV9wb3N0cyI7czoyOiIxMiI7czoyNToiZGVlcGZvY3VzX3NlYXJjaG51bV9wb3N0cyI7czoyOiIxMiI7czoyMjoiZGVlcGZvY3VzX3RhZ251bV9wb3N0cyI7czoyOiIxMiI7czoyMToiZGVlcGZvY3VzX2RhdGVfZm9ybWF0IjtzOjY6Ik0gaiwgWSI7czoyMToiZGVlcGZvY3VzX3VzZV9leGNlcnB0IjtOO3M6MTU6ImRlZXBmb2N1c19jdWZvbiI7czoyOiJvbiI7czoxNToiZGVlcGZvY3VzX3F1b3RlIjtzOjI6Im9uIjtzOjE5OiJkZWVwZm9jdXNfcXVvdGVfb25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oyOToiZGVlcGZvY3VzX3Nlb19pbmRleF9jYW5vbmljYWwiO047czozMToiZGVlcGZvY3VzX3Nlb19pbmRleF9kZXNjcmlwdGlvbiI7TjtzOjI0OiJkZWVwZm9jdXNfc2VvX2luZGV4X3R5cGUiO3M6MjQ6IkNhdGVnb3J5IG5hbWUgfCBCbG9nTmFtZSI7czoyODoiZGVlcGZvY3VzX3Nlb19pbmRleF9zZXBhcmF0ZSI7czozOiIgfCAiO3M6MzM6ImRlZXBmb2N1c19pbnRlZ3JhdGVfaGVhZGVyX2VuYWJsZSI7czoyOiJvbiI7czozMToiZGVlcGZvY3VzX2ludGVncmF0ZV9ib2R5X2VuYWJsZSI7czoyOiJvbiI7czozNjoiZGVlcGZvY3VzX2ludGVncmF0ZV9zaW5nbGV0b3BfZW5hYmxlIjtzOjI6Im9uIjtzOjM5OiJkZWVwZm9jdXNfaW50ZWdyYXRlX3NpbmdsZWJvdHRvbV9lbmFibGUiO3M6Mjoib24iO3M6MjY6ImRlZXBmb2N1c19pbnRlZ3JhdGlvbl9oZWFkIjtzOjA6IiI7czoyNjoiZGVlcGZvY3VzX2ludGVncmF0aW9uX2JvZHkiO3M6MDoiIjtzOjMyOiJkZWVwZm9jdXNfaW50ZWdyYXRpb25fc2luZ2xlX3RvcCI7czowOiIiO3M6MzU6ImRlZXBmb2N1c19pbnRlZ3JhdGlvbl9zaW5nbGVfYm90dG9tIjtzOjA6IiI7czoyMDoiZGVlcGZvY3VzXzQ2OF9lbmFibGUiO047czoxOToiZGVlcGZvY3VzXzQ2OF9pbWFnZSI7czowOiIiO3M6MTc6ImRlZXBmb2N1c180NjhfdXJsIjtzOjA6IiI7czoyMToiZGVlcGZvY3VzXzQ2OF9hZHNlbnNlIjtzOjA6IiI7fQ==';
	
	global $options;
	
	foreach ($options as $value) {
		if( isset( $value['id'] ) ) { 
			update_option( $value['id'], $value['std'] );
		}
	}
	
	$importedOptions = unserialize(base64_decode($importOptions));
	
	foreach ($importedOptions as $key=>$value) {
		if ($value != '') update_option( $key, $value );
	}
} ?>